<template>
  <div>
    <div style="height: 40px;align-content: center" >
      <span style="color: red;font-size: 5px">*注意默认只查询当天的检查数据,如果要查询其它的,请选挥范围查询</span>
    </div>
    <el-tabs value="first" class="center-tabs" stretch="true">
      <el-tab-pane label="医生工作量统计表" name="first">
        <div class="app-container">
          <el-row :gutter="24">
            <!--用户数据-->
            <el-col :span="24" :xs="24">
              <!--搜索框-->
              <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
                <el-form-item label="医生姓名" prop="dName">
                  <el-input
                    v-model="queryParams.dName"
                    placeholder="请输入医生姓名"
                    clearable
                    size="small"
                    style="width: 240px"
                    @keyup.enter.native="handleQuery"
                  />
                </el-form-item>
                <el-form-item label="就诊时间">
                  <el-date-picker
                    v-model="dateRange"
                    size="small"
                    style="width: 240px"
                    value-format="yyyy-MM-dd"
                    type="daterange"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                  <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                </el-form-item>
              </el-form>
              <el-table v-loading="loading" :data="worksList" border  show-summary>
                <el-table-column label="挂号ID" align="center" key="regId" prop="regId"  />
                <el-table-column label="医生编号" align="center" key="dId" prop="dId"   />
                <el-table-column label="医生姓名" align="center" key="dName" prop="dName"  />
                <el-table-column label="挂号费用" align="center" key="regPrice" prop="regPrice"  />
                <el-table-column label="患者姓名" align="center" key="patiName" prop="patiName"  />
                <el-table-column label="就诊时间" align="center" key="createTime" prop="createTime" >
                  <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.createTime) }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
      <el-tab-pane label="总体工作量统计表" name="second">
        <div class="app-container">
          <el-row :gutter="24">
            <!--用户数据-->
            <el-col :span="24" :xs="24">
              <!--搜索框-->
              <el-form :model="queryParams1" ref="queryForm1" :inline="true" v-show="showSearch" label-width="68px">
                <el-form-item label="医生姓名" prop="examName">
                  <el-input
                    v-model="queryParams.examName"
                    placeholder="请输入医生姓名"
                    clearable
                    size="small"
                    style="width: 240px"
                    @keyup.enter.native="handleQuery1"
                  />
                </el-form-item>
                <el-form-item label="就诊时间">
                  <el-date-picker
                    v-model="dateRange1"
                    size="small"
                    style="width: 240px"
                    value-format="yyyy-MM-dd"
                    type="daterange"
                    range-separator="-"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                  ></el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery1">搜索</el-button>
                  <el-button icon="el-icon-refresh" size="mini" @click="resetQuery1">重置</el-button>
                </el-form-item>
              </el-form>
              <el-table v-loading="loading" :data="worksList1" border show-summary >
                <el-table-column label="医生编号" align="center" key="dId" prop="dId"  />
                <el-table-column label="医生姓名" align="center" key="dName" prop="dName"   />
                <el-table-column label="挂号总额" align="center" key="regAllMoney" prop="regAllMoney"  />
                <el-table-column label="接诊数量" align="center" key="regNum" prop="regNum"  />
              </el-table>
            </el-col>
          </el-row>
        </div>
      </el-tab-pane>
  </el-tabs>
  </div>
</template>
<script>
  import { listWorks,listWorks1  } from "@/api/data/works/works";
  import { getToken } from "@/utils/auth";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";

  export default {
    name: "User",
    components: { Treeselect },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 用户表格数据
        worksList: null,
        worksList1: null,
        // 弹出层标题
        title: "",
        // 部门树选项
        deptOptions: undefined,
        // 是否显示弹出层
        open: false,
        // 部门名称
        deptName: undefined,
        // 默认密码
        initPassword: undefined,
        // 日期范围
        dateRange: [],
        dateRange1: [],
        // 状态数据字典
        statusOptions: [],
        // 性别状态字典
        sexOptions: [],
        // 岗位选项
        postOptions: [],
        // 角色选项
        roleOptions: [],
        // 用户导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: { Authorization: "Bearer " + getToken() },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/system/user/importData"
        },
        // 查询参数
        queryParams: {
          dName: undefined,
        },
        // 查询参数
        queryParams1: {
          dName: undefined,
        },
        // 列信息
        columns: [
          { key: 0, label: `用户编号`, visible: true },
          { key: 1, label: `用户名称`, visible: true },
          { key: 2, label: `用户昵称`, visible: true },
          { key: 3, label: `部门`, visible: true },
          { key: 4, label: `手机号码`, visible: true },
          { key: 5, label: `状态`, visible: true },
          { key: 6, label: `创建时间`, visible: true }
        ],
      };
    },
    created() {
      this.getList();
      this.getList1();
    },
    methods: {
      /** 查询用户列表 */
      getList() {
        this.loading = true;
        listWorks(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
            this.worksList = response.data;
            this.loading = false;
          }
        );
      },
      getList1() {
        this.loading = true;
        listWorks1(this.addDateRange(this.queryParams1, this.dateRange)).then(response => {
            this.worksList1 = response.data;
            this.loading = false;
          }
        );
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.getList();
      },
      handleQuery1() {
        this.getList1();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm("queryForm");
        this.handleQuery();
      },
      resetQuery1() {
        this.dateRange1 = [];
        this.resetForm("queryForm1");
        this.handleQuery1();
      },
      reRenderTable() {
        this.$nextTick(()=>{
          this.$refs.table.doLayout()
        })
      }
    }
  };
</script>
